package com.neusoft.nep.admin.controller;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;

import java.io.IOException;
import java.net.URL;

public class AdminIndexViewController {
    @FXML
    private ImageView imageView;
    @FXML
    private BorderPane bordPane;
    @FXML
    private StackPane stackPane;
    public void initialize() {
        System.out.println("AdminIndexViewController initialized");
        Image image = new Image("image/welcomeAdmin.png");
        this.imageView.setImage(image);
        this.imageView.fitWidthProperty().bind(this.bordPane.widthProperty());
        this.imageView.fitHeightProperty().bind(this.bordPane.heightProperty());
        this.imageView.setPreserveRatio(false);
        this.imageView.setSmooth(true);
    }

    public void loadView(String fxmlFilePath) throws IOException {
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = this.getClass().getResource(fxmlFilePath);
        fxmlLoader.setLocation(url);
        Parent root = (Parent)fxmlLoader.load();
        this.stackPane.getChildren().setAll(new Node[]{root});
    }

    public void otherStatis() throws IOException {
        this.loadView("../view/OtherTotalStatisView.fxml");
    }

    public void statisticList() throws IOException {
        this.loadView("../view/StatisticsListView.fxml");
    }

    public void aqiDistributeetotalStatisView() throws IOException {
        this.loadView("../view/AQIDistributeTotalStatisView.fxml");
    }
    public void toAQIAdminView() throws IOException {
        this.loadView("../view/AQIAdminView.fxml");
    }
    public void toProvinceAdminView() throws IOException {
        this.loadView("../view/ProvinceAdminView.fxml");
    }
    public void toTrendView() throws IOException {
        this.loadView("../view/MonthsTrendView.fxml");
    }
}
